home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / stropts.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-14  |  8.9 KB  |  231 lines  |  [TEXT/MPS ]

  1. /** Copyright (c) 1991, 1992, 1993  Mentat Inc.
  2.  ** stropts.h 4.5, last change 05 Nov 1993
  3.  ** miioccom.h 4.1, last change 31 Aug 1993
  4.  **/
  5.  
  6. #ifndef _MPS_STROPTS_
  7. #define _MPS_STROPTS_
  8.  
  9. #ifndef __OPENTRANSPORT__
  10. #include <OpenTransport.h>
  11. #endif
  12.  
  13. #if PRAGMA_ALIGN_SUPPORTED
  14. #pragma options align=mac68k
  15. #endif
  16.  
  17. #define I_NREAD         MIOC_CMD(MIOC_STREAMIO,1)        /* return the number of bytes in 1st msg */
  18. #define I_PUSH            MIOC_CMD(MIOC_STREAMIO,2)        /* push module just below stream head */
  19. #define I_POP            MIOC_CMD(MIOC_STREAMIO,3)        /* pop module below stream head */
  20. #define I_LOOK            MIOC_CMD(MIOC_STREAMIO,4)        /* retrieve name of first stream module */
  21. #define I_FLUSH         MIOC_CMD(MIOC_STREAMIO,5)        /* flush all input and/or output queues */
  22. #define I_SRDOPT        MIOC_CMD(MIOC_STREAMIO,6)        /* set the read mode */
  23. #define I_GRDOPT        MIOC_CMD(MIOC_STREAMIO,7)        /* get the current read mode */
  24. #define    I_STR            MIOC_CMD(MIOC_STREAMIO,8)        /* create an internal ioctl message            */
  25. #define I_SETSIG        MIOC_CMD(MIOC_STREAMIO,9)        /* request SIGPOLL signal on events */
  26. #define I_GETSIG        MIOC_CMD(MIOC_STREAMIO,10)        /* query the registered events */
  27. #define    I_FIND            MIOC_CMD(MIOC_STREAMIO,11)        /* check for module in stream                */
  28. #define I_LINK            MIOC_CMD(MIOC_STREAMIO,12)        /* connect stream under mux fd */
  29. #define I_UNLINK        MIOC_CMD(MIOC_STREAMIO,13)        /* disconnect two streams */
  30. #define I_PEEK            MIOC_CMD(MIOC_STREAMIO,15)        /* peek at data on read queue */
  31. #define I_FDINSERT        MIOC_CMD(MIOC_STREAMIO,16)        /* create a message and send downstream */
  32. #define I_SENDFD        MIOC_CMD(MIOC_STREAMIO,17)        /* send an fd to a connected pipe stream */
  33. #define I_RECVFD        MIOC_CMD(MIOC_STREAMIO,18)        /* retrieve a file descriptor */
  34. #define I_FLUSHBAND     MIOC_CMD(MIOC_STREAMIO,19)        /* flush a particular input and/or output band */
  35. #define I_SWROPT        MIOC_CMD(MIOC_STREAMIO,20)        /* set the write mode */
  36. #define I_GWROPT        MIOC_CMD(MIOC_STREAMIO,21)        /* get the current write mode */
  37. #define I_LIST            MIOC_CMD(MIOC_STREAMIO,22)        /* get a list of all modules on a stream    */
  38. #define I_ATMARK        MIOC_CMD(MIOC_STREAMIO,23)        /* check to see if the next message is "marked" */
  39. #define I_CKBAND        MIOC_CMD(MIOC_STREAMIO,24)        /* check for a message of a particular band */
  40. #define I_GETBAND        MIOC_CMD(MIOC_STREAMIO,25)        /* get the band of the next message to be read */
  41. #define I_CANPUT        MIOC_CMD(MIOC_STREAMIO,26)        /* check to see if a message may be passed on a stream */
  42. #define I_SETCLTIME     MIOC_CMD(MIOC_STREAMIO,27)        /* set the close timeout wait */
  43. #define I_GETCLTIME     MIOC_CMD(MIOC_STREAMIO,28)        /* get the current close timeout wait */
  44. #define I_PLINK         MIOC_CMD(MIOC_STREAMIO,29)        /* permanently connect a stream under a mux */
  45. #define I_PUNLINK        MIOC_CMD(MIOC_STREAMIO,30)        /* disconnect a permanent link */
  46.  
  47. /* ioctl values needed on non-SYS V systems */
  48. #define I_GETMSG        MIOC_CMD(MIOC_STREAMIO,40)        /* getmsg() system call */
  49. #define I_PUTMSG        MIOC_CMD(MIOC_STREAMIO,41)        /* putmsg() system call */
  50. #define I_POLL            MIOC_CMD(MIOC_STREAMIO,42)        /* poll() system call */
  51. #define I_SETDELAY        MIOC_CMD(MIOC_STREAMIO,43)        /* set blocking status */
  52. #define I_GETDELAY        MIOC_CMD(MIOC_STREAMIO,44)        /* get blocking status */
  53. #define I_RUN_QUEUES    MIOC_CMD(MIOC_STREAMIO,45)        /* sacrifice for the greater good */
  54. #define I_GETPMSG        MIOC_CMD(MIOC_STREAMIO,46)        /* getpmsg() system call */
  55. #define I_PUTPMSG        MIOC_CMD(MIOC_STREAMIO,47)        /* putpmsg() system call */
  56. #define I_AUTOPUSH        MIOC_CMD(MIOC_STREAMIO,48)        /* for systems that cannot do the autopush in open */
  57. #define I_PIPE            MIOC_CMD(MIOC_STREAMIO,49)        /* for pipe library call */
  58. #define I_HEAP_REPORT    MIOC_CMD(MIOC_STREAMIO,50)        /* get heap statistics */
  59. #define    I_FIFO            MIOC_CMD(MIOC_STREAMIO,51)        /* for fifo library call */
  60.  
  61. /* priority message request on putmsg() or strpeek */
  62. #define RS_HIPRI        0x1
  63.  
  64. /* flags for getpmsg and putpmsg */
  65. #define MSG_HIPRI        RS_HIPRI
  66. #define MSG_BAND        0x2             /* Retrieve a message from a particular band */
  67. #define MSG_ANY         0x4             /* Retrieve a message from any band */
  68.  
  69. /* return values from getmsg(), 0 indicates all ok */
  70. #define MORECTL         0x1     /* more control info available */
  71. #define MOREDATA        0x2     /* more data available */
  72.  
  73. #ifndef FMNAMESZ
  74. #define FMNAMESZ        31    /* maximum length of a module or device name */
  75. #endif
  76.  
  77. /* Infinite poll wait time */
  78. #define INFTIM            -1
  79.  
  80. /* flush requests */
  81. #define FLUSHR            0x1             /* Flush the read queue */
  82. #define FLUSHW            0x2             /* Flush the write queue */
  83. #define FLUSHRW         (FLUSHW|FLUSHR) /* Flush both */
  84. #define FLUSHBAND        0x40            /* Flush a particular band */
  85.  
  86. /* I_FLUSHBAND */
  87. struct bandinfo 
  88. {
  89.     unsigned char    bi_pri;         /* Band to flush */
  90.     int             bi_flag;        /* One of the above flush requests */
  91. };
  92.  
  93. /* flags for I_ATMARK */
  94. #define ANYMARK         0x1             /* Check if message is marked */
  95. #define LASTMARK        0x2             /* Check if this is the only message marked */
  96.  
  97. /* signal event masks */
  98. #define S_INPUT         0x1     /* A non-M_PCPROTO message has arrived */
  99. #define S_HIPRI         0x2     /* A priority (M_PCPROTO) message is available */
  100. #define S_OUTPUT        0x4     /* The write queue is no longer full */
  101. #define S_MSG            0x8     /* A signal message has reached the front of read queue */
  102. #define S_RDNORM        0x10    /* A non-priority message is available */
  103. #define S_RDBAND        0x20    /* A banded messsage is available */
  104. #define S_WRNORM        0x40    /* Same as S_OUTPUT */
  105. #define S_WRBAND        0x80    /* A priority band exists and is writable */
  106. #define S_ERROR         0x100    /* Error message has arrived */
  107. #define S_HANGUP        0x200    /* Hangup message has arrived */
  108. #define S_BANDURG        0x400    /* Use SIGURG instead of SIGPOLL on S_RDBAND signals */
  109.  
  110. /* read mode bits for I_S|GRDOPT; choose one of the following */
  111. #define RNORM            0x01    /* byte-stream mode, default */
  112. #define RMSGD            0x02    /* message-discard mode */
  113. #define RMSGN            0x04    /* message-nondiscard mode */
  114. #define RFILL            0x08    /* fill read buffer mode (PSE private) */
  115.  
  116. /* More read modes, these are bitwise or'ed with the modes above */
  117. #define RPROTNORM        0x10    /* Normal handling of M_PROTO/M_PCPROTO messages, default */
  118. #define RPROTDIS        0x20    /* Discard M_PROTO/M_PCPROTO message blocks */
  119. #define RPROTDAT        0x40    /* Convert M_PROTO/M_PCPROTO message blocks into M_DATA */
  120.  
  121. /* write modes for I_S|GWROPT */
  122. #define SNDZERO         0x1     /* Send a zero-length message downstream on a write of zero bytes */
  123.  
  124. #define MUXID_ALL        -1        /* Unlink all lower streams for I_UNLINK and I_PUNLINK */
  125.  
  126. struct strbuf 
  127. {
  128.     int     maxlen;         /* max buffer length */
  129.     int     len;            /* length of data */
  130.     char*    buf;            /* pointer to buffer */
  131. };
  132.  
  133. /* structure of ioctl data on I_FDINSERT */
  134. struct strfdinsert 
  135. {
  136.     struct strbuf    ctlbuf;
  137.     struct strbuf    databuf;
  138.     long            flags;    /* type of message, 0 or RS_HIPRI */
  139.     long            fildes; /* fd of other stream (FDCELL) */
  140.     int             offset; /* where to put other stream read qp */
  141. };
  142.  
  143. /* I_LIST structures */
  144. struct str_list 
  145. {
  146.     int     sl_nmods;                /* number of modules in sl_modlist array */
  147.     struct str_mlist* sl_modlist;
  148. };
  149.  
  150. struct str_mlist 
  151. {
  152.     char    l_name[FMNAMESZ + 1];
  153. };
  154.  
  155. /* I_PEEK structure */
  156. struct strpeek 
  157. {
  158.     struct strbuf    ctlbuf;
  159.     struct strbuf    databuf;
  160.     long            flags;    /* if RS_HIPRI, get priority messages only */
  161. };
  162.  
  163. struct strpmsg                 /* structure for getpmsg and putpmsg */
  164. {
  165.     struct strbuf    ctlbuf;
  166.     struct strbuf    databuf;
  167.     int             band;
  168.     long            flags;
  169. };
  170.  
  171. /* structure of ioctl data on I_RECVFD */
  172. struct strrecvfd 
  173. {
  174.     long            fd;     /* new file descriptor (FDCELL) */
  175.     unsigned short    uid;    /* user id of sending stream */
  176.     unsigned short    gid;
  177.     char            fill[8];
  178. };
  179.  
  180. /* structure of ioctl data on I_STR */
  181. struct strioctl 
  182. {
  183.     int     ic_cmd;         /* downstream command */
  184.     int     ic_timout;        /* ACK/NAK timeout */
  185.     int     ic_len;         /* length of data arg */
  186.     char*    ic_dp;        /* ptr to data arg */
  187. };
  188.  
  189. #if !OTKERNEL
  190.  
  191. #ifdef __cplusplus
  192. extern "C" {
  193. #endif
  194.  
  195. pascal    int getmsg(int fd, struct strbuf* ctlbuf, struct strbuf* databuf, int* flagsp);
  196. pascal    int putmsg(int fd, const struct strbuf* ctlbuf, const struct strbuf* databuf, int flags);
  197. pascal    int getpmsg(int fd, struct strbuf* ctlbuf, struct strbuf* databuf, int* bandp, int* flagsp);
  198. pascal    int putpmsg(int fd, const struct strbuf* ctlbuf, const struct strbuf* databuf, int band, int flags);
  199. //
  200. // These are here for compatibility with the rest of xti, but are not the preferred interfaces.
  201. //
  202. #ifdef __OPENTRANSPORT__
  203. pascal int    stream_installnotifier(int fd, OTNotifyProcPtr, void* contextPtr);
  204. pascal int    stream_blocking(int fd);
  205. pascal int    stream_nonblocking(int fd);
  206. pascal int    stream_isblocking(int fd);
  207. pascal int    stream_synchronous(int fd);
  208. pascal int    stream_asynchronous(int fd);
  209. pascal int    stream_issynchronous(int fd);
  210. #endif
  211. pascal int    stream_open(char* path, unsigned long);
  212. pascal int    stream_close(int fd);
  213. pascal int    stream_read(int fd, void* buf, size_t len);
  214. pascal int    stream_write(int fd, void* buf, size_t len);
  215.        int    stream_ioctl(int fd, unsigned long type, ...);
  216. pascal int    stream_pipe(int*);
  217. pascal int    poll(struct pollfd* fds, size_t nfds, unsigned long timeout);
  218.  
  219. #ifdef __cplusplus
  220. }
  221. #endif
  222.  
  223. #endif /* OTKERNEL */
  224.  
  225. #if PRAGMA_ALIGN_SUPPORTED
  226. #pragma options align=reset
  227. #endif
  228.  
  229. #endif    /* ifdef _STROPTS_ */
  230.  
  231.